/**
 * @file   Host.hpp
 * @author Yuan Liu <liuyuan@net.pku.edu.cn>
 * @date   Sat Jun 23 15:41:51 2007
 *
 * @brief DNS cache and Robots cache
 *
 * Class Host is used to :
 *  1 Map a domain string such as "www.pku.edu.cn" into IP string type "162.105.129.12".
 *  2 Parse the domain's robots.txt and store the rules
 */

#ifndef __HOST_HPP
#define __HOST_HPP

#include <string>
#include <vector>
#include <map>

#include "Url.hpp"


struct Host_Elem
{
    std::string              IP;
    std::vector<std::string> RobotRules;
};

class Host
{
public:
    /**
     * Get the IP and robots rules under a domain
     *
     * @param crHostName Domain's name
     *
     * @return Struct of IP and robots rules
     */
    Host_Elem GetElem(const std::string& crHostName);

private:
    Host_Elem AddHostElem(const std::string& crHostName);
    std::string GetIpByHost(const std::string& crHost);
    std::vector<std::string> GetRobotRules(const std::string& crHost,
                                           const std::string& crIP);

private:
    std::map<const std::string, Host_Elem> mHostMap;
};

#endif
